package com.object.module.cbb.controller;

import com.object.configuration.utils.PageUtils;
import com.object.configuration.utils.Q;
import com.object.module.cbb.entity.CddShopEntity;
import com.object.module.cbb.service.CddShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * @author 小🌤
 * @email 1578442339@qq.com
 * @date 2022-03-28 11:17:49
 */
@RestController
@RequestMapping("/cbb/cddshop")
public class CddShopController {
    @Autowired
    private CddShopService cddShopService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public Q list(@RequestParam Map<String, Object> params) {
        PageUtils page = cddShopService.queryPage(params);
        return Q.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{spId}")
    public Q info(@PathVariable("spId") Integer spId) {
        CddShopEntity cddShop = cddShopService.getById(spId);
        return Q.ok().put("cddShop", cddShop);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public Q save(@RequestBody CddShopEntity cddShop) {
        cddShopService.saveShop(cddShop);
        return Q.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public Q update(@RequestBody CddShopEntity cddShop) {
        cddShopService.updateById(cddShop);
        return Q.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public Q delete(@RequestBody Integer[] spIds) {
        cddShopService.removeByIds(Arrays.asList(spIds));
        return Q.ok();
    }

}
